import LXCOM from '../../../common/common.js'
var LMosDragTool = {

}

LMosDragTool.action = function (dataManger, mosEvnt, tPoint, preLMosDownPt) {
    var nModifyInfo = 0;
    var tValidPoint = new LXCOM.LGXPoint();
    tValidPoint.clone(tPoint);

    var tOrignalPoint = new LXCOM.LGXPoint();
    tOrignalPoint.clone(tPoint);

    var offsetPt = new LXCOM.LGXPoint();
    offsetPt.x = tPoint.x - preLMosDownPt.x;
    offsetPt.y = tPoint.y - preLMosDownPt.y;
    var nMosMovDis = offsetPt.x * offsetPt.x + offsetPt.y * offsetPt.y;
    if (nMosMovDis > 0) {
        nModifyInfo = this.modifyCurentGraph(dataManger, offsetPt, mosEvnt);
    }
    return nModifyInfo;
}


LMosDragTool.modifyCurentGraph = function(dataManger, offsetPt, mosEvnt)
{
    var pCurentGraph = dataManger.getCurentGraph();
    if (pCurentGraph == null) {
        return 0;
    }

    if (pCurentGraph.getSelKind() == 0) {
        return 0;
    }

    var shiftdown = mosEvnt.shiftKey;
    var ctrlKeyDown = mosEvnt.ctrlKey;
    this.modifyGraphByOffset(dataManger,pCurentGraph, offsetPt, false, shiftdown, ctrlKeyDown);
    return 1;
}

LMosDragTool.modifyGraphByOffset = function(dataManger,pGraph, offsetPt, shiftdown, ctrldown)
{
    var cmdinfo = new LXCOM.LXModifyCMDInfo();
    cmdinfo.mapscale = dataManger.getMapScale();
    cmdinfo.scaling = dataManger.getScaling();
    cmdinfo.ctrldown = ctrldown;
    cmdinfo.shiftdown = shiftdown;
    var failed = pGraph.modifyByOffset(offsetPt, cmdinfo);
    return failed;
}



export default { LMosDragTool }